<#zone title="个人资料" validate="true">
	<ol class="breadcrumb hidden-xs mb20">
		<li class="active">空间</li>
		<li class="active">修改个人信息</li>
	</ol>
	<ol class="breadcrumb visible-xs mb20">
		<li>
			<a href="#offcanvas" data-toggle="offcanvas">空间</a>
		</li>
		<li class="active">修改个人信息</li>
	</ol>
	<!-- 表单 -->
	<form class="form-horizontal" method="post" id="userDataForm">
		<div class="form-group">
			<label class="control-label col-md-2">昵称</label>
			<div class="col-md-8">
				<input class="form-control" type="text" name="user.nickname" required remote="/me/data/checkName"
				minlength="1" maxlength="10" value="${session.user.nickname}">
				<p class="form-control-static text-muted">昵称保持在3-10个字符，不能包含:,;&lt;&gt;&@[]和空格</p>
			</div>	
		</div>
		<div class="form-group">
			<label class="control-label col-md-2">签名</label>
			<div class="col-md-8">
				<textarea class="form-control" rows="3" cols="" maxlength="100" 
				name="user.signature" placeholder="个性签名在100字以内">${session.user.signature!}</textarea>
			</div>	
		</div>
		<div class="form-group">
			<div class="col-md-3 col-md-offset-2">
				<button type="submit" class="btn btn-primary btn-block">提交保存</button>
			</div>
			<div class="col-md-7 text-danger" id="msg"></div>
		</div>
	</form>
	<script>
		$(function(){
			$("#userDataForm").validate({
				messages:{
					nickname:{
						remote:"该昵称已经被使用了，请换一个"
					}
				},
				submitHandler:function(form){
					$(form).find(":submit").button("loading");
					$(form).ajaxSubmit({
						url:"/me/data/update",
						success:function(json){
							$(form).find(":submit").button("reset");
							var msg = "保存成功";
							if(!json.ok){
								msg = json.msg;
							}
							var timeId = $("#msg").data("time-id");
							if(timeId){
								clearTimeout(timeId);
							}
							$("#msg").html(msg);
							timeId = setTimeout(function(){
								$("#msg").empty();	
							}, 2000);
							$("#msg").data("time-id",timeId)
						}
					});
				}
			});
		});
	</script>
</#zone>